package com.intramirror.product.schedule;

import com.intramirror.product.schedule.consumer.ConsumerThread;
import com.intramirror.product.service.FacilityService;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created on 2018/3/12.
 * @author Admin
 */
@Component
public class SnapshotManager {

    @Autowired
    FacilityService facilityService;

    @Autowired
    KafkaProperties kafkaProperties;

    @PostConstruct
    public void startConsumerKafka() {

        List<KafkaItem> items = kafkaProperties.getKafka();
        for (KafkaItem item : items) {
            ExecutorService executor = Executors.newFixedThreadPool(1);
            executor.execute(new ConsumerThread(item, facilityService));
        }
    }
}
